//异步串行的保险钩子
const {AsyncSeriesBailHook} = require('tapable');
class Module{}
class NormalModule extends Module{
    constructor(name){super();this.name = name}
}
class ExternalModule extends Module{
    constructor(name){super();this.name = name}
}
let factorize = new AsyncSeriesBailHook(["resolveData"]);
//bail就是如果当前的钩子函数返回了值，那么就会直接跳过后面的所有钩子函数，直接结束 
factorize.tapAsync('tap1',(resolveData,callback)=>{
    //你要创建的模块是jquery
    if(resolveData === 'jquery'){
        callback(null,new ExternalModule('jQuery'))
    }else{
        callback(null,undefined);
    }
});
//默认逻辑
factorize.tapAsync('tap2',(resolveData,callback)=>{
    callback(null,new NormalModule('jquery'))
    //createdModule = new NormalModule(createData);
});
factorize.callAsync('jquery',(err,module)=>{
    console.log(module);
});
